package com.ryskoo.permission.permission.service;

import com.ryskoo.framework.core.service.BasicServiceImpl;
import com.ryskoo.permission.permission.domain.PermissionPO;
import com.ryskoo.permission.permission.repository.IPermissionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author Shawn
 */
@Service
public class PermissionServiceImpl extends BasicServiceImpl<PermissionPO> implements IPermissionService {
	@Autowired
	private IPermissionRepository permissionRepository;

	@PostConstruct
	public void init() {
		this.setDao(permissionRepository);
	}

	@Override
	public List<PermissionPO> getPermissionByRoleId(String roleId) {
		return permissionRepository.getPermissionByRoleId(roleId);
	}

	
	/**
	 * 初始化权限,根据角色获取权限列表，放入缓存
	 * 后台管理员和商户登录时，根据登录角色，缓存获取权限
	 * @return
	 */
	@Override
	public void initPermission() {
		permissionRepository.initPermission();
	}
}
